package TCP.translation;

import TCP.EchoServer.TcpThreadPoolEchoServer;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class TcpDictServer extends TcpThreadPoolEchoServer {

    private Map<String,String> map = new HashMap<>();

    public TcpDictServer(int port) throws IOException {
        super(port);
        map.put("cat","小猫咪~");
        map.put("dog","小狗勾~");
        map.put("pig","小猪~");
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,"没有该单词!");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer server = new TcpDictServer(9090);
        server.start();
    }
}
